#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
int n, m;
int v[10001];
int w[10001];
int s[10001];
int dp[100001];
int cnt[10001];
int main()
{
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++) {
        scanf("%d %d %d", &v[i], &w[i], &s[i]);
    }
    for (int i = 1; i <= n; i++) {
        for (int p = m; p >= v[i]; p--) {
            for (int k = 1; k <= s[i]; k++) {
                if (v[i] * k > p) break;
                dp[p] = max(dp[p], dp[p - v[i] * k] + w[i] * k);
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= m; i++) {
        ans = max(ans, dp[i]);
    }
    printf("%d", ans);
    return 0;
}